﻿//#define _CRT_SECURE_NO_WARNINGS
//#include<stdio.h>
//#include<stdlib.h>
//#include<time.h>
//int main()
//{
//	srand((unsigned int)time(NULL));
//	printf("%d\n", rand());
//	printf("%d\n", rand());
//	printf("%d\n", rand());
//	printf("%d\n", rand());
//	printf("%d\n", rand());
//	return 0;
//}
//生成0-99之间的随机数：rand()%100;
//生成1-100之间的随机数：rand()%100+1;
//生成100-200之间的随机数：100+rand()%(200-100+1);
//                         100+rand()%101;
//生成a-b的随机数：a+rand()%(b-a+1);
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void menu()
{
    printf("****** 猜数字游戏 *****\n");
    printf("***********************\n");
    printf("***********************\n");
    printf("***** 1.开始游戏 ******\n");
    printf("***** 0.退出游戏 ******\n");
    printf("***********************\n");
    printf("***********************\n");
}
void game()
{
    int standard = rand() % 100 + 1;
    int guess = 0;
    printf("请猜数字>>>    \n");
    do
    {
        scanf("%d", &guess);
        if (guess < standard)
        {
            printf("猜小了\n");
        }
        else if (guess > standard)
        {
            printf("猜大了\n");
        }
        else
        {
            printf("恭喜你，猜对了\n");
            break;
        }
    } while (1);
}
int main()
{
    srand((unsigned int)time(NULL));
    int input = 0;
    do
    {
        menu();//调用menu函数
        printf("请选择>>>");
        scanf("%d", &input);
        switch (input)
        {
        case 1:
            printf("Go!(ง •_•)ง>>>>>>\n");
            game();
            break;
        case 0:
            printf("Bye~(T_T)\n");
            break;
        default:
            printf("Wrong choice.(╯▔皿▔)╯\n");
            break;
        }
    } while (input);
    return 0;
}